import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/common/network_image_util.dart';
import 'package:xinxuan/utils/color_util.dart';

class GoodsInfoCommon extends StatelessWidget {

  final String title;
  final String headImage;
  final String price;
  final int quantity;
  GoodsInfoCommon({
    required this.title,
    required this.headImage,
    required this.price,
    required this.quantity
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(bottom: 12.h),
      child: Row(
        children: [
          NetworkImageUtil(
            url: headImage, 
            width: 90.w, 
            height: 90.w,
            borderRadius: 5.w,
          ),
          SizedBox(width: 12.w),
          Expanded(child: Container(
            constraints: BoxConstraints(
              minHeight: 90.w
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  overflow: TextOverflow.ellipsis,
                  maxLines: 2,
                  style: TextStyle(
                    color: textBlackColor,
                    fontSize: 14.sp
                  ),
                ),
                SizedBox(height: 6.h),
                Row(
                  children: [
                    Expanded(child: Text(
                      '¥$price',
                      style: TextStyle(
                        color: mainTextColor,
                        fontSize: 14.sp,
                        fontWeight: FontWeight.bold
                      )
                    )),
                    Text(
                      'x$quantity',
                      style: TextStyle(
                        color: textSubtitleColor,
                        fontSize: 14.sp,
                        fontWeight: FontWeight.bold
                      )
                    ),
                  ],
                )
              ],
            ),
          )),
        ],
      ),
    );
  }
}